/**
 * 
 */
package business;

import java.util.ArrayList;

import dbAccess.CommandeEtuDBAccess;

import exceptions.*;

import model.*;

/**
 * @author Anthares & Hennek
 *
 */
public class CommandeEtuManager {
	private SyllabusManager sylMan = new SyllabusManager();
	private CommandeEtuDBAccess comdba = new CommandeEtuDBAccess();
	
	public double getPrixCommande(Object object) throws PasIdentificationException, DatabaseErrorException, InvalidDataException{
		double prixCom = 0;
		if(object==null) throw new InvalidDataException();
		if(object.getClass().equals(ArrayList.class)) {
			ArrayList<Syllabus> object2 = (ArrayList<Syllabus>)object;
			for(Syllabus s: object2){
				prixCom+=sylMan.getPrixSyllabus(s);
			}
		}
		return prixCom;
	}
	public void addCommandeEtu(Commande_etu com) throws PasIdentificationException, DatabaseErrorException, InvalidDataException{
		if(com==null) throw new InvalidDataException();
		comdba.addCommande(com);
	}
	/**
	 * @param annee
	 * @param section_id
	 * @return
	 * @throws DatabaseErrorException 
	 * @throws PasIdentificationException 
	 * @throws InvalidDataException 
	 */
	public ArrayList<Commande_etu> getAllCommandeEtu(int annee, int section_id, ArrayList<String> etats) throws PasIdentificationException, DatabaseErrorException, InvalidDataException {
		if(annee<0 || annee>3 || section_id<0) throw new InvalidDataException();
		return comdba.getAllCommandeEtu(annee, section_id, etats);
	}
	
	public void modifCommandeEtu(Commande_etu com) throws PasIdentificationException, DatabaseErrorException, InvalidDataException{
		if(com==null) throw new InvalidDataException();
		comdba.modifCommandeEtu(com);
	}
	public void delCommandeEtu(Commande_etu com) throws PasIdentificationException, DatabaseErrorException, InvalidDataException{
		if(com==null) throw new InvalidDataException();
		comdba.deleteCommandeEtu(com);
	}
	public int getNbrComEtu() throws PasIdentificationException, DatabaseErrorException{
		return comdba.getNbrComEtu();
	}
}
